package com.muyu.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.system.domain.SysRoleDept;
import com.muyu.system.mapper.SysRoleDeptMapper;
import com.muyu.system.service.SysRoleDeptService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * 角色与部门关联业务实现
 * @author dongzeliang
 * @version 1.0
 * @description: 角色与部门关联业务实现
 * @date 2025/2/13 19:43
 */
@Service
public class SysRoleDeptServiceImpl extends ServiceImpl<SysRoleDeptMapper, SysRoleDept> implements SysRoleDeptService {
    /**
     * 通过角色ID删除角色和部门关联
     *
     * @param roleId 角色ID
     */
    @Override
    public void deleteRoleDeptByRoleId(Long roleId) {
        LambdaQueryWrapper<SysRoleDept> lambdaQueryWrapper = new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, roleId);
        this.remove(lambdaQueryWrapper);
    }

    /**
     * 通过角色ID删除角色与部门关联
     *
     * @param roleIds 角色ID集合
     */
    @Override
    public void deleteRoleDept(List<Long> roleIds) {
        LambdaQueryWrapper<SysRoleDept> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.in(SysRoleDept::getRoleId, roleIds);
        this.remove(lambdaQueryWrapper);
    }
}
